from suds.client import Client
import json

# 创建头部管理
header = {}
# 创建一个客户端去请求服务器
client = Client("http://testingedu.com.cn:8081/inter/SOAP?wsdl")
# 从客户端获取服务，然后通过服务名调用接口
# 如果接口不接收参数，或者多传了参数都会报错
# 反射
result = client.service.__getattr__('auth')()
jsonres = json.loads(result)
header['token'] = jsonres['token']
client = Client("http://testingedu.com.cn:8081/inter/SOAP?wsdl", headers=header)

result = client.service.register('Tester9527','123456','测试账号')
print(result)

# 参数
params = ['Will','123456']
# 如果服务器500会报错
result = client.service.login(*params)
print(result)
result = client.service.getUserInfo('1')
print(result)
result = client.service.logout()
print(result)
